package com.chen.springboot.mapper.uniapp;

import com.chen.springboot.dto.uniapp.Category;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CategoryMapper {

    @Select("SELECT id, name, picture FROM category WHERE parent_id IS NULL")
    List<Category> selectRootCategories();

    @Select("SELECT id, name, picture, parent_id AS parentId FROM category WHERE parent_id = #{parentId}")
    List<Category> selectSubCategories(String parentId);

    @Select("SELECT image_url FROM category_images WHERE category_id = #{categoryId}")
    List<String> selectImageBanners(String categoryId);

}
